home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.01 Jan 90 / DLL Source Code / SampFHF.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-27  |  1.6 KB  |  59 lines  |  [TEXT/MPS ]

  1. /************************************************/
  2. /*                  Sample DLL's                */
  3. /*       Copyright © Vincent Parsons 1989.      */
  4. /************************************************/
  5. /*    DLL code for MPW C 3.0 or THINK C 4.0     */
  6. /*       with Excel for the Macintosh 2.2       */
  7. /*             and Microsoft C 5.1              */
  8. /*          with Excel for Windows 2.1          */
  9. /************************************************/
  10. /* SampFHF is an example of one data type H     */
  11. /* input and one data type F output.  The       */
  12. /* output is the ASCII hex representation of    */
  13. /* the type H input.  The answer has been       */
  14. /* stored in the Excel buffer reserved by the   */
  15. /* type F input variable.                       */
  16. /************************************************/
  17. /*   =REGISTER("SampDLLs","SampFHF","FHF")      */
  18. /*   for both the Mac and the PC.               */
  19. /************************************************/
  20.  
  21. #include "DLL.h"
  22.  
  23. #if applec
  24. #include <Types.h>
  25.  
  26. #elif MSDOS
  27. #include <windows.h>
  28.  
  29. #endif
  30.  
  31. #if THINK_C
  32. pascal char * main(unsigned short u1, char * c1);    /* prototype */
  33.  
  34. pascal char * main(u1, c1)
  35. unsigned short u1;
  36. char * c1;
  37.  
  38. #elif applec
  39. pascal char * SampFHF(unsigned short u1, char * c1)
  40.  
  41. #elif MSDOS
  42. char far * far pascal SampFHF(unsigned short u1, char far * c1)
  43. #endif
  44. {
  45.     short i;
  46.     
  47.     for (i = 3; i >= 0; i--) {    /* C String */
  48.         c1[i] = u1 & 0xF;            /* Get nibble */
  49.         if (c1[i] <= 9) c1[i] += '0';
  50.         else c1[i] += 55;            /* Make ASCII hex */
  51.         u1 = u1 >> 4;                /* Get next nibble */
  52.     }
  53.     c1[4] = 0;
  54.     
  55.     return (c1);
  56. }
  57.  
  58. /************************************************/
  59.